package com.lagou.jdbc01;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * @Author wsl
 * @Date 2021/8/17 23:19
 * @Project_Name mysql
 */
public class JdbcDemo01 {

    public static void main(String[] args) throws Exception {

        //1.注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //2.获取连接 url,用户名,密码
        String url = "jdbc:mysql://localhost:3306/db4?characterEncoding=UTF-8";
        Connection con = DriverManager.getConnection(url, "root", "123456");

        //com.mysql.jdbc.JDBC4Connection@4524411f
        //System.out.println(con);
        //3.获取Statement对象
        Statement statement = con.createStatement();
        //3.1通过 statement对象的 executeUpdate 方法创建一张表
        String sql = "create table test(id int,name varchar(20),age int);";
        int i = statement.executeUpdate(sql);

        System.out.println(i);//0

        //4.关闭流
        statement.close();
        con.close();
    }
}
